package com.manage.modules.controller;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.manage.common.annotation.Log;
import com.manage.common.core.controller.BaseController;
import com.manage.common.core.domain.AjaxResult;
import com.manage.common.enums.BusinessType;
import com.manage.modules.vo.TBaseDataTransferVo;
import com.manage.modules.bo.TBaseDataTransferQueryBo;
import com.manage.modules.bo.TBaseDataTransferAddBo;
import com.manage.modules.bo.TBaseDataTransferEditBo;
import com.manage.modules.service.ITBaseDataTransferService;
import com.manage.common.utils.poi.ExcelUtil;
import com.manage.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 数据传输统计Controller
 *
 * @author wx
 * @date 2021-09-15
 */
@Api(value = "数据传输统计控制器", tags = {"数据传输统计管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/modules/dataTransfer")
public class TBaseDataTransferController extends BaseController {

    private final ITBaseDataTransferService iTBaseDataTransferService;

    /**
     * 查询数据传输统计列表
     */
    @ApiOperation("查询数据传输统计列表")
    @PreAuthorize("@ss.hasPermi('modules:dataTransfer:list')")
    @GetMapping("/list")
    public TableDataInfo<TBaseDataTransferVo> list(TBaseDataTransferQueryBo bo) {
        startPage();
        List<TBaseDataTransferVo> list = iTBaseDataTransferService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出数据传输统计列表
     */
    @ApiOperation("导出数据传输统计列表")
    @PreAuthorize("@ss.hasPermi('modules:dataTransfer:export')")
    @Log(title = "数据传输统计", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<TBaseDataTransferVo> export(TBaseDataTransferQueryBo bo) {
        List<TBaseDataTransferVo> list = iTBaseDataTransferService.queryList(bo);
        ExcelUtil<TBaseDataTransferVo> util = new ExcelUtil<TBaseDataTransferVo>(TBaseDataTransferVo.class);
        return util.exportExcel(list, "数据传输统计");
    }

    /**
     * 获取数据传输统计详细信息
     */
    @ApiOperation("获取数据传输统计详细信息")
    @PreAuthorize("@ss.hasPermi('modules:dataTransfer:query')")
    @GetMapping("/{id}")
    public AjaxResult<TBaseDataTransferVo> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(iTBaseDataTransferService.queryById(id));
    }

    /**
     * 新增数据传输统计
     */
    @ApiOperation("新增数据传输统计")
    @PreAuthorize("@ss.hasPermi('modules:dataTransfer:add')")
    @Log(title = "数据传输统计", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody TBaseDataTransferAddBo bo) {
        return toAjax(iTBaseDataTransferService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改数据传输统计
     */
    @ApiOperation("修改数据传输统计")
    @PreAuthorize("@ss.hasPermi('modules:dataTransfer:edit')")
    @Log(title = "数据传输统计", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody TBaseDataTransferEditBo bo) {
        return toAjax(iTBaseDataTransferService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除数据传输统计
     */
    @ApiOperation("删除数据传输统计")
    @PreAuthorize("@ss.hasPermi('modules:dataTransfer:remove')")
    @Log(title = "数据传输统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iTBaseDataTransferService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
